import { ref } from "vue";
import type { Ref } from "vue";
import { defineStore } from "pinia";
import { fetchMedicListAPI } from "@/api/homeApi/homeApi.ts";
import type { PageParams } from "@/types/homeTypes/homeTypes.ts";
import type { DoctorPage } from "@/types/homeTypes/homeTypes.ts";
import homeStoreInterface from "@/pinia/modules/homeStore/interface.ts";


const useHomeStore = defineStore("homeStore", (): homeStoreInterface => {

   const medicList: Ref<DoctorPage> = ref<DoctorPage>(<DoctorPage>{});

   const fetchMedicList = async (params: PageParams): Promise<void> => {
      const { data }: { data: DoctorPage } = await fetchMedicListAPI(params);
      medicList.value=data
   };

   return {
      medicList,
      fetchMedicList,
   };
});

export default useHomeStore;
